home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-04 | 7.0 KB | 207 lines | [TEXT/MPS ] |
- //----------------------------------------------------------------------------------------
- // UViewSkeleton.cp
- // Copyright © 1991-96 by Apple Computer, Inc. All rights reserved.
- //----------------------------------------------------------------------------------------
-
- #ifndef __UVIEWSKELETON__
- #include "UViewSkeleton.h"
- #endif
-
- #ifndef __UMACAPPUTILITIES__
- #include "UMacAppUtilities.h"
- #endif
-
- #ifndef __UDOCUMENTSKELETON__
- #include "UDocumentSkeleton.h"
- #endif
-
- #ifndef __UTRACKERSKELETON__
- #include "UTrackerSkeleton.h"
- #endif
-
- #ifndef __UMENUMGR__
- #include "UMenuMgr.h"
- #endif
-
- #ifndef __FONTS__
- #include "Fonts.h"
- #endif
-
- //----------------------------------------------------------------------------------------
- // Constants:
-
- const CommandNumber cCommandHandledByView = 402;
-
- //========================================================================================
- // Global Initialization Procedure
- //========================================================================================
- #undef Inherited
-
- //----------------------------------------------------------------------------------------
- // InitUViewSkeleton:
- //----------------------------------------------------------------------------------------
- #pragma segment DlgInit
-
- void InitUViewSkeleton()
- {
- // So the linker doesn't dead strip class info
- MA_REGISTER_CLASS(TViewSkeleton);
- } // InitUViewSkeleton
-
-
- //========================================================================================
- // CLASS TViewSkeleton
- //========================================================================================
- #undef Inherited
- #define Inherited TView
-
- #pragma segment AOpen
- MA_DEFINE_CLASS_M1(TViewSkeleton, Inherited);
-
- //----------------------------------------------------------------------------------------
- // TViewSkeleton constructor
- //----------------------------------------------------------------------------------------
- #pragma segment AOpen
-
- TViewSkeleton::TViewSkeleton()
- {
- fDocumentSkeleton = NULL;
- } // TViewSkeleton::TViewSkeleton
-
- //----------------------------------------------------------------------------------------
- // TViewSkeleton destructor
- //----------------------------------------------------------------------------------------
- #pragma segment MADestructorRes
-
- TViewSkeleton::~TViewSkeleton()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // TViewSkeleton::IViewSkeleton:
- //----------------------------------------------------------------------------------------
- #pragma segment AOpen
-
- void TViewSkeleton::IViewSkeleton(TDocumentSkeleton* itsDocumentSkeleton,
- TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize)
- {
- this->IView(itsDocumentSkeleton,itsSuperView,itsLocation,itsSize,sizeFixed, sizeFixed);
-
- fDocumentSkeleton = itsDocumentSkeleton;
- } // TViewSkeleton::IViewSkeleton
-
- //----------------------------------------------------------------------------------------
- // TViewSkeleton::Draw:
- //----------------------------------------------------------------------------------------
- #pragma segment ARes
-
- void TViewSkeleton::Draw(const VRect& area) // Override
- {
- const VCoordinate boxHeight = 50;
- const long nRows = fSize.v / boxHeight;
- const VPoint increment(fSize.h / nRows, boxHeight);
-
- VRect aVRect(gZeroVPt, increment); // construct the rect at top left of view.
-
- PenNormal();
- PenPat(&qd.ltGray);
-
- for (long row = 0; row < nRows; row++)
- {
- if (!(area & aVRect).Empty())
- PaintRect(&ViewToQDRect(aVRect));
-
- if (!row) // draw title over first rect, regardless of rect's visibility.
- {
- VRect stringRect(aVRect);
- stringRect.right += 400;
- if (!(area & stringRect).Empty())
- {
- TextFont(times); // a nice outline font
- TextSize((short)stringRect.GetLength(vSel));
- MADrawString("Skeleton Application",ViewToQDRect(stringRect),teFlushDefault,TRUE);
- }
- }
-
- aVRect += increment; // move rect after drawing.
- }
- } // TViewSkeleton::Draw
-
- //----------------------------------------------------------------------------------------
- // TViewSkeleton::DoMenuCommand: This method is overridden to handle menu items which are
- // enabled when this view is in the target chain. In this example, this is true when the
- // window containing this view is the active window. The inherited method should always be
- // called so that MacApp can allow successor objects in the target chain (i.e. document
- // and application) to handle THEIR menu items.
- //----------------------------------------------------------------------------------------
- #pragma segment ASelCommand
-
- void TViewSkeleton::DoMenuCommand(CommandNumber aCommandNumber) // Override
- {
- switch (aCommandNumber)
- {
- case cCommandHandledByView :
- SysBeep(2);
- break;
-
- default:
- Inherited::DoMenuCommand(aCommandNumber);
- break;
- }
- } // TViewSkeleton::DoMenuCommand
-
- //----------------------------------------------------------------------------------------
- // TViewSkeleton::DoPostCreate:
- //----------------------------------------------------------------------------------------
- #pragma segment AOpen
-
- void TViewSkeleton::DoPostCreate(TDocument* itsDocument) // Override
- {
- Inherited::DoPostCreate(itsDocument);
-
- fDocumentSkeleton = (TDocumentSkeleton*) itsDocument;
- } // TViewSkeleton::DoPostCreate
-
- //----------------------------------------------------------------------------------------
- // TViewSkeleton::DoSetupMenus: This method is overridden to enable menu items which
- // should be enabled when this view is in the target chain. MacApp initially disables all
- // menu items, then lets the objects in the target chain enable those items they handle.
- //
- // A view is generally in the target chain when its window is the active window, and the
- // view or one of its subviews is designated as the target of that window. In this
- // example, the window's resource specifies the skeleton view as the target.
- //
- // The inherited method is called so that objects further up the target chain (the
- // scroller, window, document and application) can set up THEIR menus.
- //----------------------------------------------------------------------------------------
- #pragma segment ARes
-
- void TViewSkeleton::DoSetupMenus() // Override
- {
- Inherited::DoSetupMenus();
- Enable(cCommandHandledByView,TRUE);
- // EnableCheck(cCommandHandledByView,true,true);
- } // TViewSkeleton::DoSetupMenus
-
- //----------------------------------------------------------------------------------------
- // TViewSkeleton::DoMouseCommand:
- //----------------------------------------------------------------------------------------
- #pragma segment ASelCommand
-
- void TViewSkeleton::DoMouseCommand(VPoint& theMouse,
- TToolboxEvent* /* event */,
- CPoint /* hysteresis */) // Override
- {
- TTrackerSkeleton* aTracker = new TTrackerSkeleton;
-
- aTracker->ITrackerSkeleton(fDocumentSkeleton, this, this->GetScroller(FALSE), theMouse);
- this->PostCommand(aTracker);
- } // TViewSkeleton::DoMouseCommand
-
- //----------------------------------------------------------------------------------------
- // End of UViewSkeleton.cp
-
- #pragma segment Inline
-